{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">发票列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('invoice.invoice/add')}"
               data-auth-edit="{:$auth->check('invoice.invoice/edit')}"
               data-auth-delete="{:$auth->check('invoice.invoice/del')}"
        ></table>
    </div>
</div>

<script type="text/html" id="barTool">

<!--    <a onclick="wk.layer_show('详情','{:url('detail')}?id={{d.id}}',300,true)"-->
<!--       class="layui-btn layui-bg-cyan layui-btn-xs" title="订单详情">商品详情</a>-->
    <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('invoice.invoice/edit')?'':'layui-hide'}" title="编辑"><i class='iconfont icon-brush_fill'>发票详情</i></a>
    {if isset($status)}
    {if $status==1}
    <!--    <a href='{:url("fa")}?id={{ d.id }}'-->
    <!--       class="layui-btn layui-btn-danger layui-btn-xs confirm">确认发货</a>-->
    <!--    <a class="layui-btn layui-btn-sm confirm" data-href='{:url("fa")}?id={{ d.id }}' data-batch-all="currentTable">-->
    <!--        <i class="iconfont icon-right"></i>审核通过</a>-->
    {/if}
    {/if}
    <!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('invoice.invoice/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>&ndash;&gt;-->
    <!--    <a onclick="wk.layer_show('编辑用户','{:url('edit_vip')}?id={{d.u_id}}')" class="layui-btn layui-btn-xs" title="编辑"><i class="fa fa-pencil"></i></a>-->

    <!--    <a href="javascript:;" onclick="wk.confirm('{{d.u_id}}','{:url('del_vip')}')" class="layui-btn layui-btn-danger layui-btn-xs" title="删除"><i class="fa fa-trash-o"></i></a>-->

</script>
<!--<script type="text/html" id="barTool">-->
<!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('invoice.invoice/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>-->

<!--&lt;!&ndash;    <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('auth.rule/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>&ndash;&gt;-->
<!--</script>-->

<!--操作模板-->

{/block}
{block name="script"}
<script>

    layui.use(['yznTable', 'table'], function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        table.render({
            elem: '#currentTable',
            init: init,
            autoWidth: true,
            toolbar: ['refresh', [{
                html: ' {if $status==0}<a class="layui-btn layui-btn-sm confirm" data-href="{:url("ca")}" data-batch-all="currentTable"><i class="iconfont icon-right"></i>选择开票</a> {/if}',
                auth: 'pass',
            }]],
            url: '{:url("index")}?status={$status}',
            // search: false,
            cols: [
                [

                    //1直接购买订单 2购买水票订单  type

                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: 50, title: 'ID', search: false},
                    {field: 'order_no', Width: 110, title: '订单编号'},
                    // {field: 'member_id', title: '用户id', width: 80},
                    // {field: 'member_id', title: '用户名称', width: 80,search: false},
                    {field: 'price', Width: 120, title: '订单金额', search: false},
                    { //发票类型 1个人 2企业 invoice_type
                        field: 'invoice_type', Width: 60, title: '发票类型', templet: function (d) {
                            if (d.invoice_type == 1) {
                                return '<span style="color: orange">个人</span>';
                            } else if (d.invoice_type == 2) {
                                return '<span style="color: green">企业</span>';
                            }
                        }, selectList: { 1: '个人', 2: '企业'},
                    },
                    {  //1直接购买订单 2购买水票订单  type
                        field: 'type', Width: 90, title: '订单类型', templet: function (d) {
                            if (d.type == 1) {
                                return '<span style="color: red">商品订单</span>';
                            } else {
                                return '<span style="color: green">水票订单</span>';
                            }
                        }, selectList: {1: '商品订单', 2: '水票订单'},
                    },

                    // {  // `status` int(2) DEFAULT '0' COMMENT '0待开 1已开',
                    //     field: 'status', Width: 90, title: '订单类型', templet: function (d) {
                    //         if (d.status == 1) {
                    //             return '<span style="color: red">直接购买订单</span>';
                    //         } else {
                    //             return '<span style="color: green">购买水票订单</span>';
                    //         }
                    //     }, selectList: {0: '直接购买订单', 1: '购买水票订单'},
                    // },

                    {field: 'create_time', Width: 150, title: '申请时间', search: 'range'},
                    {fixed: 'right', align: 'center', Width: 50, title: '操作', toolbar: '#barTool'}//delete'
                ]
            ],
            page: {}
        });
        table.bindevent();
    });
</script>
{/block}